within ThreeD_MBS_Dynamics.Examples.Snakeboard;

model Test_WheelSet_with_Bar
  // One WheelSet with Bar
  parameter SI.Acceleration g=9.81;
  parameter SI.Acceleration[3] Gravity={0,-g,0};
  parameter SI.Mass m_bar=1;
  // Radius of Disc
  parameter SI.Radius r1=1;
  // Radius of Rod
  parameter SI.Radius r2=0.1;
  // Radius of Initial Position
  parameter SI.Radius R=1;
  // Horizontal Length of Rod
  parameter SI.Length L=3;
  // Length of Bar
  parameter SI.Length LD=8;
  // Width of Bar
  parameter SI.Length WD=0.8;
  // Height of Bar
  parameter SI.Length HD=0.2;
  parameter SI.Length h=0.1 + r2 + HD/2;
  // parameter SI.AngularVelocity omega0=1;
  parameter SI.AngularVelocity omega1=0.8;
  parameter SI.Angle phi1=0.1;
  //  parameter Real phi1=Modelica.Constants.pi/6;
  parameter SI.Angle phi2=-Modelica.Constants.pi/8;
  parameter SI.Position[3] r0={-0.5*LD,r1,0};
  //  parameter Real[3] v0={-r1*omega0 - 0.5*L*omega1,0,0};
  parameter SI.Velocity[3] v0={0,0,0};
  RollingWheelSet WheelSet1(
    Gravity=Gravity,
    r1=r1,
    r2=r2,
    L=L,
    r0=r0,
    v0=v0,
    omega1=omega1,
    phi=phi1) annotation (extent=[-44,-20; -4,20]);
  SemiBar Bar1(
    Gravity=Gravity,
    m=m_bar,
    LD=LD,
    WD=WD,
    HD=HD,
    q(start={1,0,0,0}),
    I=m_bar/12*[LD^2 + HD^2, 0, 0; 0, WD^2 + HD^2, 0; 0, 0, LD^2 + WD^2],
    v(start=v0),
    omega(start={0,0,0}),
    r(start={0,r1 + h,0})) annotation (extent=[52,-20; 92,20]);
  Base Base1 annotation (extent=[-92,-20; -52,20]);
  FixedJoint Joint1(
    nA={0,1,0},
    nB={0,1,0},
    rA={0,h,0},
    rB={-0.5*LD,0,0}) annotation (extent=[4,-20; 44,20]);
  annotation (
    Diagram,
    experiment(
      StopTime=30,
      NumberOfIntervals=10000,
      Tolerance=1e-012),
    experimentSetupOutput,
    DymolaStoredErrors);
equation
  connect(WheelSet1.OutPortBase, Base1.OutPort) 
    annotation (points=[-30,-18; -30,-30; -72,-30; -72,-18]);
  connect(WheelSet1.InPortJoint, Joint1.OutPortA) 
    annotation (points=[-24,18; -24,30; 18,30; 18,18]);
  connect(Joint1.OutPortB, Bar1.InPortJointA) 
    annotation (points=[30,18; 30,30; 62,30; 62,18]);
  connect(WheelSet1.OutPortJoint, Joint1.InPortA) 
    annotation (points=[-18,-18; -18,-30; 18,-30; 18,-18]);
  connect(Joint1.InPortB, Bar1.OutPort) 
    annotation (points=[30,-18; 30,-30; 72,-30; 72,-18]);
end Test_WheelSet_with_Bar;
